package Chess.GUI;

import javax.swing.JPanel;
import javax.swing.ImageIcon;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Graphics;

/**
 *	A class to support a background image for a JPanel.
 *
 *	@author		Jeff Chan
 */
public class ImagePanel extends JPanel {
	private Image bg;
	
	/**
	 *	Constructs an ImagePanel of a given image location
	 *
	 *	@param	img		the location of the background image
	 */
	public ImagePanel(String img) {
		this.bg = new ImageIcon(img).getImage();
		Dimension size = new Dimension(bg.getWidth(null), bg.getHeight(null));
	}
	
	/**
	 *	Paints the JPanel with the background image.
	 *
	 *	@param	g	the Graphics pane
	 */
	public void paintComponent(Graphics g) {
		g.drawImage(bg, 0, 0, null);
	}
}